package com.dubbo.consumer.quickstart;

import com.dubbo.service.ServiceApi;
import org.mengyun.tcctransaction.api.Compensable;
import org.mengyun.tcctransaction.dubbo.context.DubboTransactionContextEditor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class QuickstartConsumer {

    @Autowired
    private ServiceApi serviceApi;

    @Compensable(confirmMethod = "confirmSendMessage",cancelMethod = "canceSendMessage",transactionContextEditor = DubboTransactionContextEditor.class)
    public void sendMessage(String message){
        String temp1 = serviceApi.saveOrder("11","22","33");
        boolean notSold = serviceApi.isNotSold("45");
        boolean trueSeats = serviceApi.isTrueSeats("1,2,3");
    }
    public void confirmSendMessage(String message){
        System.out.println("this is consumer confirmSendMessage"+message);
        String temp = serviceApi.sendMessage(message);
        System.out.println(temp);
    }
    public void canceSendMessage(String message){
        System.out.println("this is consumer canceSendMessage"+message);
        String temp = serviceApi.sendMessage(message);
        System.out.println(temp);
    }
}
